<template>
  <div class="lower-wrapper">
    <div class="invite-title"><a href="javascript:;" @click="returnHref"><img src="../../assets/img/return.png"></a><p>今日推广费</p></div>
    <div class="lower-head">
      <ul>
        <li>
          <label>开始时间：</label>
          <el-date-picker
            v-model="startDate"
            type="date"
            placeholder="选择日期"
            :editable="false"
            size="mini"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </li>
        <li>
          <label>结束时间：</label>
          <el-date-picker
            v-model="endDate"
            :editable="false"
            type="date"
            size="mini"
            placeholder="选择日期"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </li>
        <li><h3>推广费总计：<span>{{moneyTotal | fixed}}</span>元</h3></li>
        <li><a href="javascript:;" @click="getScan">搜索</a></li>
      </ul>
    </div>
    <div class="lower-content">
      <el-table
        :data="tableData"
        v-loading="listLoading"
        stripe
        style="width: 100%">
        <el-table-column
          prop="userid"
          label="玩家ID"
          width="80">
        </el-table-column>
        <el-table-column
          prop="nickname"
          label="昵称"
          min-width="120">
          <template slot-scope="scope">
            <span >{{scope.row.nickname | baseName}}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="type"
          label="类型"
          width="80">
          <template slot-scope="scope">
            <span v-text="scope.row.isAgent ? '代理':'玩家'"></span>
          </template>
        </el-table-column>
        <el-table-column
          prop="amount"
          label="提成"
          width="100">
          <template slot-scope="scope">
            <span>{{scope.row.amount | fixed}}</span>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        background
        :pager-count="5"
        layout="prev, pager, next"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
    export default {
        name: "today",
      data(){
          return{
            moneyTotal:0,
            startDate:'',
            pageIndex:1,
            pageSize:this.global().pageSize,
            total:0,
            endDate:'',
            listLoading:false,
            tableData:[]
          }
      },
      created(){
        this.startDate = this.Todate1(new Date(new Date()),'yyyy-MM-dd HH:mm:ss')
        this.endDate =  this.Todate(new Date(new Date()),'yyyy-MM-dd')
        this.getScan();
      },
      methods:{
        returnHref(){
          this.$router.go(-1)
        },
        getScan(){
          let start = '';
          let end = '';
          this.listLoading = true;
          if(this.startDate){ start = Date.parse(this.startDate)}
          if(this.endDate){ end = Date.parse(this.endDate)}
          this.$axios.get('/income-statistics/three-level?starttime='+start+'&endtime='+end+'&index='+this.pageIndex+'&size='+this.pageSize,{},this.global().token).then((res)=>{
            if(res.status == 200){
              let userData = res.data.data
              this.total = res.data.count
              if(res.data.amount){
                this.moneyTotal = res.data.amount
              }
              this.tableData = userData
              this.listLoading = false;
            }
          })
        }
      }
    }
</script>

<style scoped lang="stylus">
  @import "../../assets/css/title.styl"
  @import "../../assets/css/table.styl"
  .lower-head
    &>ul>li>label
      flex 0 0 1rem
</style>
